<div id='user_table_tb' class="form-inline">
	<div class="input-group">
		<!--手机号搜索-->
		<input type="text" placeholder="请输入手机号" id="searchContext" class="form-control"/>
		<span class="input-group-btn"> 
			<button type="button" class="btn btn-primary" onclick="searchPhone()">搜索</button>
		</span>
		
		<!--日期搜索-->
		
	</div>
</div>

<div class="container">
	<div class="row">
		<div class="col-lg-12">
			<div class="ibox float-e-margins">
				<div class="ibox-content">
					<div class="m-t-sm">
						<div class="alert alert-success" id="examplebtTableEventsResult" role="alert">
							APP用户总量： <span class="label label-danger">298w</span>
						</div>
						
						<!--<div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
														<button type="button" class="btn btn-outline btn-default"><i class="fa fa-user-md" aria-hidden="true"></i></button>
													</div>-->
						<table id="userTable" data-height="400" data-mobile-responsive="true">
							<thead>
								<tr>
									<th data-field="id" data-checkbox='true'>id</th>
									<th data-field="nickname">用户昵称</th>
									<th data-field="gender">性别</th>
									<th data-field="email">邮箱</th>
									<th data-field="phoneNumber">手机号</th>
									<th data-field="integral">积分</th>
									<th data-field="quan">打印券</th>
									<th data-field="isPrivilege" data-formatter="fmtPrivilege">用户类型</th>
									<th data-field="deleteFlag" data-formatter="fmtDleteFlag">是否冻结</th>
								</tr>
							</thead>
						</table>
					</div>
					<!--<div class="m-t-md">
						<small class="pull-right">
                                        <i class="fa fa-clock-o"> </i>
                                        2015.02.30更新
                                    </small>
						<small>
                                        <strong>说明：</strong> 本期销售额比上期增长了23%。
                                    </small>
					</div>-->

				</div>
			</div>
		</div>
	</div>
</div>

<script>
	/*初始化table数据*/
	$('#userTable').bootstrapTable({
		toolbar:'#user_table_tb',
		url: "/bzas/user/selectAllUser", //数据抓取地址  json/User.json
		pagination: true, //显示分页插件
		sidePagination: 'server',
		showColumns: true,
		showRefresh: true,
		onLoadSuccess: function(data) {
		    console.info(data);
			console.log(new Date());
			$('#refreshTime').text(new Date());
			//解决bt的bug,初始化全选取消。
			$('#userTable th input').click();
		}
	});
	/*格式化显示用户类型字段
	 	value: 值
	 	row：行数据
	 	index：下标
	 **/
	function fmtPrivilege(value, row, index) {
		return value == '0' ? '普通用户' : '白名单用户'
	};
	/**
	 * 格式化显示是否冻结列
	 */
	function fmtDleteFlag(value, row, index) {
		return value == '0' ? '<span class="label label-primary">激活</span>' : '冻结';
	};

    /**
	 * 根据手机号查询一条用户信息
	 * 是否需要根据名字查询？
	 *
     */
    function searchPhone() {

		var searchContext = $("#searchContext").val();
		console.info(searchContext);
        //发送ajax请求
        $.ajax({
            type: "post",
            url: "/bzas/user/searchUserByPhone",
            data: {searchContext : searchContext},
            dataType:"json",
            success : function(json) {
                $("#userTable").bootstrapTable('load', json);//主要是要这种写法
            }
        });

    };
</script>